///String manipulation class definitions
//
//Copyright Embedded Systems Technologies All Rights Reserved
//
/*******************************************************************************
 * Author     : Mike Glavin
 * Description:
 *******************************************************************************/
#ifndef CLI_STRING__MODULE_INC
#define CLI_STRING__MODULE_INC

#include <time.h>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <iterator>
#include <vector>
#include <fstream>
#include <sys/stat.h>

using namespace std;

const char CLI_STRING[] = "CLI_STRING";
const char CLI_STRING_VERSION[] = "Version 0.1";

class Ccli_string
{
public:

    Ccli_string();
    ~Ccli_string();

    string extract_nchars_before_string(size_t nchars, string needle, string haystack);
    string extract_allchars_before_string(string needle, string haystack);
    string extract_allchars_before_string_including(string needle, string haystack);
    string extract_filename(string haystack);
    string extract_nchars_after_string(size_t nchars, string needle, string haystack);
    string extract_all_after_string(string needle, string haystack);
    string extract_nchars_after_string_inc(size_t nchars, string needle, string haystack);
    string extract_all_after_string_inc(string needle, string haystack);
    string extract_all_after_string_inc(string needle, vector<string> haystack);
    vector<string> extract_lines_from_string(string haystack);
    string remove_whitespace_from_string(string haystack);
    string remove_tabs_from_string(string haystack);
    string remove_endl_from_string(string haystack);
    string remove_char_from_string(char thechar, string haystack);
    string remove_cr_from_string(string haystack);
    string remove_all_from_string(string haystack);
    vector<string> read_file_lines(string filename, vector<string> *);
    size_t write_file_lines(string filename, vector<string> v);
    string extract_numbers_from_string(string haystack);
    string system_string(string system_cmd);
    size_t system_string(string system_cmd, vector<string> *vres);
    void system_auto_install_fmaa(char *ip_addr);
    string get_localtime_string();
    size_t stat_file(string filename);

protected:

private:
    string sresult;
    vector<string> vresult;
    FILE *cmd_stream;
    int c;
    int error;
    char buff[8192*1024];

    time_t t;
    struct tm *t_m;

};

#endif ///CLI_STRING__MODULE_INC



